// 文章相关接口
import { request } from "@/utils";

// 获取频道
export const getChannelAPI = () => {
  return request({
    url: "/channels",
    method: "GET",
  });
};

// 新增
export const addChannelAPI = (channel) => {
  return request({
    url: "/mp/articles?draft=false",
    method: "POST",
    data: channel,
  });
};

// 获取文章列表
export const getArticleListAPI = (params) => {
  return request({
    url: "/mp/articles",
    method: "GET",
    params,
  });
};

// 删除文章
export const deleteArticleAPI = (id) => {
  return request({
    url: `/mp/articles/${id}`,
    method: "DELETE",
  });
};

// 获取详情
export const getArticleDetailAPI = (id) => {
  return request({
    url: `/mp/articles/${id}`,
    method: "GET",
  });
};

// 修改文章
export const updateArticleAPI = (data) => {
  return request({
    url: `/mp/articles/${data.id}?draft=false`,
    method: "PUT",
    data,
  });
};
